#include<iostream>
using namespace std;
const int N = 10100;
int arr[N];
int n;
int main()
{
	cin >> n;
	int ans = 0;
	for (int i = 0 ,j =; i < n; i++) {
		int a;
		cin >> a;
		arr[a]++;
		while (arr[a] > 1) {
			arr[a]--;
			j++;e
		}
		ans = max(ans, i - j + 1);
	}
	cout << ans << endl;
	return 0;
}